<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <link rel="icon" type="image/svg+xml" href="/vite.svg" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Vite + Vue + TS</title>
    </head>
    <body>
        <div id="app"></div>

        <div class="body-dialog">这是app后面的div</div>
        <script type="module" src="/src/main.ts"></script>
    </body>
    <style>
        body {
            overflow: hidden;
        }
        .body-dialog {
            background-color: #ff0;
        }
    </style>
    <script>
        window.onload = function () {
            let titleDom = document.querySelector('title')
            let title = ''
            // window.on
            window.onpagehide = () => {
                title = titleDom.innerText
                titleDom.innerText = '我在想你,快回来'
                console.log('page hide:', titleDom)
                console.log(title)
                // document.title = '我在想你'
            }
            window.onpageshow = () => {
                titleDom.innerText = title
                // document.title = title
            }
            document.onvisibilitychange = (event) => {
                console.log('visibility change:', event)
                if (window.document.visibilityState === 'hidden') {
                    title = titleDom.innerText
                    titleDom.innerText = '我在想你,快回来'
                } else {
                    titleDom.innerText = title
                }
            }
        }
    </script>
</html>
